CC = gcc
EXE = tset
CUR_DIR = $(shell pwd)

DIR_SYS_SRC = $(CUR_DIR)/state_machine
DIR_SYS_INC = $(CUR_DIR)/state_machine/include

DIR_DEMO1_SRC = $(CUR_DIR)/demo_task

DIR_OBJ = $(CUR_DIR)/obj

SRC += $(wildcard $(DIR_SYS_SRC)/*.c)
SRC += $(wildcard $(DIR_DEMO1_SRC)/*.c)

OBJ = $(patsubst %.c, $(DIR_OBJ)/%.o, $(notdir $(SRC)))
DEP := $(patsubst %, $(DIR_OBJ)/%.d, $(notdir $(OBJ)))

CFLAGS = -I $(DIR_SYS_INC)

$(EXE) : $(OBJ)
	$(CC) -o $@ $^

$(OBJ) : $(SRC)
	$(CC) $(CFLAGS) -c -o $@ $< -MD -MF $@.d
-include $(DEP)

.PHONY : clean
	
clean :
	rm $(DIR_OBJ)/*.o $(DIR_OBJ)/*.d $(EXE)

# ALL:
# 	@echo DIR_SYS_SRC = $(DIR_SYS_SRC)
# 	@echo DIR_SYS_INC = $(DIR_SYS_INC)
# 	@echo DIR_OBJ = $(DIR_OBJ)
# 	@echo SRC = $(SRC)
# 	@echo OBJ = $(OBJ)	
# 	@echo DEP = $(DEP)


